﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Linq;

namespace SAP_dll
{
    public class SAP400
    {
        sap400.service s = new sap400.service();
        sap400.ZwsEquiMatDataResponse r;
        sap400.ZwsEquiMatData p = new sap400.ZwsEquiMatData();
        ArrayList proc = new ArrayList();
        ArrayList ser = new ArrayList();
        ArrayList mac = new ArrayList();
        ArrayList tip = new ArrayList();
        ArrayList status = new ArrayList();

        public void getData(string nalog)
        {
            sap400.ZstWsEquiMatData podatki = new sap400.ZstWsEquiMatData();
            podatki.Aufnr = nalog;
            p.Input = podatki;
            s.Credentials = new System.Net.NetworkCredential("web", "prenos");
            r = s.ZwsEquiMatData(p);

            //string[,] x = new string[r.Output.Length, 2];

            foreach (sap400.ZstWsEquiMatData data in r.Output)
            {
                proc.Add(data.Zsrtiv);
                ser.Add(data.Serge);
                mac.Add(data.Zmac);
                tip.Add(data.Auart);
                status.Add(data.Pstat);
            }

            if (r.Return.Type != "S")
                throw new System.Exception(r.Return.Message);


        }

        public string tipDN()
        {
            if (tip.ToArray().Length > 1)
                return tip[0].ToString();
            else
                return string.Empty;
        }

        public string statusDN()
        {
            if (status.ToArray().Length > 1)
                return status[0].ToString();
            else
                return string.Empty;
        }

        public ArrayList MacSAP()
        {
            return mac;
        }
        public ArrayList SerijskeSAP()
        {
            return ser;
        }

        public ArrayList ProcesneSAP()
        {
            return proc;
        }


    }


}
